<template>
	<view class="container">
		<view class="chanpin-device" >
			<view class="">
				产品:{{fromData?.name}}
			</view>
			<view class="">
				需求:{{fromData?.product_uom_qty}}
			</view>
			<view class="">
				完成数量:{{fromData?.quantity_done}}
			</view>
			<view class="">
				预留数量:{{fromData?.reserved_availability}}
			</view>
		</view>
		<view class="item-box" v-if="fromData">
			<view class="item" v-for="(item,i) in fromData.move_line_list" @click="gotoMessage(item.move_line_id)">
				<view class="">
					从:{{item?.location_id}}
				</view>
				<view class="">
					批次/序号:{{item?.lot_id}}
				</view>
				<view class="">
				</view>
				<view class="">
					已预留:{{item?.product_uom_qty}}
				</view>
				<view class="">
					完成:{{item?.qty_done}}
				</view>
				<view class="">
					计量单位:{{item?.product_uom_id}}
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		getJiaohuoChanpinMessage
	} from '@/api/jiaohuo.js'
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app'
	import {
		ref,
		reactive
	} from 'vue'

	const fromData = ref({})
	const id = ref('')
	const _getJiaohuoChanpinMessage = () => {
		getJiaohuoChanpinMessage(id.value).then((res) => {
			console.log('产品信息',res);
			fromData.value = res.result
		})
	}

	onLoad((option) => {
		console.log('上级传入', option);
		id.value = option.id
		_getJiaohuoChanpinMessage()
	})
	
	const gotoMessage = (id) => {
		console.log('id',id);
		uni.navigateTo({
			url:`/model/jiaohuoModel/jiaohuo_lable_view?id=${id}`
		})
	}

</script>

<style lang="scss" scoped>
	.container {
		padding: 10rpx;
		min-height: 100vh;
		background-color: #f5f5f5;
		
		.item-box {
			margin-top: 10px;
			.item {
				display: grid;
				grid-template-columns: repeat(3,1fr);
				gap: 10px;
				text-align: center;
				margin-bottom: 10px;
				padding: 10px;
				background-color: #ffffff;
				border: 1px solid gainsboro;
			}
		}
		
	
	}
</style>